<?php
/**
 * Created by PhpStorm.
 * User: lixy
 * Date: 2017/1/17
 * Time: 9:33
 */
use yii\helpers\Url;

$web = Url::base();
?>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" type="text/css" href="<?=$web?>/css/mall/home-login.css"/>
    <script src="<?= $web ?>/js/jquery-1.10.2.min.js"></script>
    <script src="<?= $web ?>/js/tools.js"></script>
</head>

<body>

<div class="integral">
    <img class="login-log" src="<?=$web?>/images/mall/login-logo.png"/>
    <p class="slogan">尊敬的用户，欢迎您回来</p>
    <p class="tell-phone">客户服务：400-860-3111</p>
</div>
<div class="login-bg">
    <div class="login">
        <img class="login-txt-img" src="<?=$web?>/images/mall/login-txt-img.png"/>
        <div class="login-content">
            <div class="choose">
                <div class="important-login"><span class="choose-cur important-login-btn">VIP登录</span></div>
                <div class="line"></div>
                <div class="direct-login"><span class="direct-login-btn">直接登录</span></div>
            </div>
            <div class="content-1" >
                <div class="serial-number">
                    <input type="text" name="" id="card_voucher1" value="" />
                    <p class="name">编号：</p>
                </div>
                <div class="password">
                    <input type="text" name="" id="card_token1" value="" />
                    <p class="name">密码：</p>
                </div>
                <div class="phone-num">
                    <input type="text" name="" id="phone1" value="" />
                    <p class="name">手机号码：</p>
                </div>
                <div class="code">
                    <a href="#" id="btnSms1" class="code-btn">获取短信验证码</a>
                    <input type="text" name="" id="smsCode1" value="" />
                    <p class="name">验证码：</p>
                </div>
                <a href="javascript:vip_login()" class="login-btn1">登录</a>
            </div>

            <div class="content-2" style="display: none;">
                <div class="phone-num">
                    <img class="name-img" src="<?=$web?>/images/mall/shurushoujihaoma.jpg"/>
                    <input type="text-1" class="phone-num-txt" id="phone2" value="" placeholder="输入您的手机号码"/>
                </div>
                <div class="password">
                    <img class="text-img" src="<?=$web?>/images/mall/denglumima.jpg"/>
                    <input type="text" class="password-num-2" id="smsCode2" value="" placeholder="输入短信验证码"/>
                    <a href="#" id="btnSms2" class="code-btn">获取验证码</a>
                </div>
                <a href="javascript:normal_login()" class="login-btn2">登录</a>
            </div>
            <script type="text/javascript">
                $(function(){
                    $(".direct-login-btn").click(function(){
                        $(".content-1").hide();
                        $(".content-2").show();
                        $(this).addClass("choose-cur");
                        $(".important-login-btn").removeClass("choose-cur");
                    });
                    $(".important-login-btn").click(function(){
                        $(".content-2").hide();
                        $(".content-1").show();
                        $(this).addClass("choose-cur");
                        $(".direct-login-btn").removeClass("choose-cur");
                    });
                });
            </script>
        </div>


    </div>
</div>
<div class="new-footer" >
    <div class="foot-top-border"></div>
    <div class="footer-content">
        <div class="wechat">
            <div class="accounts">
                <img src="<?=$web?>/images/mall/duolahe-weixin.jpg" />
                <p>微信公众号</p>
                <p>扫码关注我们</p>
            </div>

        </div>
        <div class="corporate-information">
            <p>全国服务热线：400-860-3111</p>
            <p>联系电话：131  4839  4117</p>
            <p>联系地址：重庆市江北区海尔路178号美全22世纪A座3楼</p>
            <p>重庆鑫泰科技有限责任公司版权所有 Copyright©2016 All Rights Reserved | 渝ICP备15012802号</p>
        </div>
    </div>
</div>
<script type="text/javascript">
    function vip_login(){
        var verification_code=$('#smsCode1').val();
        var card_voucher=$('#card_voucher1').val();
        var card_token=$('#card_token1').val();
        var phone=$('#phone1').val();
        if(verification_code.length==0){
            alert('请输入验证码');
            return;
        }
        if(phone.length==0){
            alert('请输入手机号');
            return;
        }
        if(card_voucher.length==0){
            alert('请输入编码');
            return;
        }
        if(card_token.length==0){
            alert('请输入密码');
            return;
        }
        var re=requestJson('home-vip-login-handle',{
            verification_code:verification_code,
            card_voucher:card_voucher,
            card_token:card_token,
            phone:phone
        });
        if(re.status==0){
            //成功
            window.location.href="<?=Url::to(['mall/index'])?>?institution_code="+re.data.institution_code+'&card_id='+re.data.card_id;
        }else{
            alert(re.message);
        }
    }
    var is_loading_sms_1=false;
    $(function () {
        $('#btnSms1').click(function () {
            if(is_loading_sms_1){
                return;
            }
            is_loading_sms_1=true;
            $(this).html('正在获取...');
            var phone = $('#phone1').val().trim();
            if (phone.length == 0) {
                alert('请输入手机号码');
                $(this).html('获取验证码');
                $('#phone1').focus();
                is_loading_sms_1=false;
                return;
            }
            var that = this;
            requestJson('home-send-login-sms-verification-code-handle', {phone: phone,type:'vip'}, true, function (responseData) {
                if (responseData.status != 0) {
                    $(that).html('获取验证码');
                    is_loading_sms_1=false;
                    alert(responseData.message);
                } else {
                    verifyTimeoutValue = 60;
                    verifyTimeout();
                }
            }, function () {
                $(that).html('获取验证码');
                is_loading_sms_1=false;
            });
        });

        $('#phone1').focus();
    });

    var verifyTimeoutValue = 0;
    function verifyTimeout() {
        if (verifyTimeoutValue > 0) {
            $('#btnSms1').html('重新获取(' + verifyTimeoutValue + ')');
            verifyTimeoutValue--;
            setTimeout(verifyTimeout, 1000);
        } else {
            $('#btnSms1').html('获取验证码');
            is_loading_sms_1=false;
        }
    }
</script>
<script type="text/javascript">
    function normal_login(){
        var verification_code=$('#smsCode2').val();
        var phone=$('#phone2').val();
        if(verification_code.length==0){
            alert('请输入验证码');
            return;
        }
        if(phone.length==0){
            alert('请输入手机号');
            return;
        }
        var re=requestJson('home-normal-login-handle',{
            verification_code:verification_code,
            phone:phone,
        });
        if(re.status==0){
            //成功
            window.location.href="<?=Url::to(['mall/inst-list'])?>";
        }else{
            alert(re.message);
        }
    }
    var is_loading_sms_2=false;
    $(function () {
        $('#btnSms2').click(function () {
            if(is_loading_sms_2){
                return;
            }
            is_loading_sms_2=true;
            $(this).html('正在获取...');
            var phone = $('#phone2').val().trim();
            if (phone.length == 0) {
                alert('请输入手机号码');
                $(this).html('获取验证码');
                $('#phone1').focus();
                is_loading_sms_2=false;
                return;
            }
            var that = this;
            requestJson('home-send-login-sms-verification-code-handle', {phone: phone,type:'normal'}, true, function (responseData) {
                if (responseData.status != 0) {
                    $(that).html('获取验证码');
                    is_loading_sms_2=false;
                    alert(responseData.message);
                } else {
                    verifyTimeoutValue2 = 60;
                    verifyTimeout2();
                }
            }, function () {
                $(that).html('获取验证码');
                is_loading_sms_2=false;
            });
        });

        $('#phone2').focus();
    });

    var verifyTimeoutValue2 = 0;
    function verifyTimeout2() {
        if (verifyTimeoutValue2 > 0) {
            $('#btnSms2').html('重新获取(' + verifyTimeoutValue2 + ')');
            verifyTimeoutValue2--;
            setTimeout(verifyTimeout2, 1000);
        } else {
            $('#btnSms2').html('获取验证码');
            is_loading_sms_2=false;
        }
    }
</script>
</body>

</html>
